#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<ll, ll>
#define fi first
#define se second
#define N 111111
#define L 1111111
ll n, m, t, len, lim, d[N], v[N], a[N], p[N], vis[L], ck[N], pre[L], nxt[L], cnt;
vector<ll> qry[L];
ll calc(ll v, ll a, ll d){
    return v * v + 2 * a * d;
}
ll cals(ll sv, ll ev, ll a){
    return (ev * ev - sv * sv);
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%lld", &t);
    while (t--)
    {
        scanf("%lld%lld%lld%lld", &n, &m, &len, &lim);
        ++len;
        for(int i = 1 ; i <= n ; i++){
            scanf("%lld%lld%lld", &d[i], &v[i], &a[i]);
            ++d[i];
        }
        memset(vis, 0, sizeof vis);
        cnt = 0;
        for(int i = 1 ; i <= m ; i++){
            scanf("%lld", &p[i]);
            ++p[i];
            vis[p[i]] = true;
        }
        nxt[len + 1] = len + 1;
        for(int i = 1 ; i <= len ; i++){
            if(qry[i].size())
                qry[i].clear();
            if(vis[i])
                pre[i] = i;
            else
                pre[i] = pre[i - 1];
        }
        for(int i = len ; i >= 1 ; i--){
            if(vis[i])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        }
        for(int i = 1 ; i <= n ; i++){
            if(nxt[d[i]] > len)
                continue;
            bool bj = 0;
            if(calc(v[i], a[i], nxt[d[i]] - d[i]) > lim * lim){
                cnt++;
                bj = 1;
            }
            else if(calc(v[i], a[i], pre[len] - d[i]) > lim * lim){
                cnt++;
                bj = 1;
            }
            //cerr << calc(v[i], a[i], pre[len] - d[i]) << " " << i << " " << v[i] << " " << bj << "\n";
            if(!bj)
                continue;
            if(a[i] > 0){
                ll l = d[i] + (cals(v[i], lim, a[i]) + 2 * a[i] - 1) / (2 * a[i]);
                qry[len].push_back(max(l, d[i]));
            }
            else if(a[i] == 0){
                qry[len].push_back(d[i]);
            }
            else{
                ll r = d[i] + (cals(v[i], lim, a[i]) + 1) / (2 * a[i]);
                qry[min(r, len)].push_back(d[i]);
            }
            // if(v[i] > lim)
            //     cerr << v[i] << " \n"[i == n];
        }
        if(*max_element(a + 1, a + 1 + n) == 0){
            printf("%lld %lld\n", cnt, m - !!(cnt));
            continue;
        }
        ll ans = 0;
        for(ll r = 1, tmp = 0 ; r <= len ; r++){
            if(!qry[r].size())
                continue;
            bool bj = 0;
            for(auto l : qry[r])
                if(l > tmp){
                    bj = true;
                    tmp = pre[r];
                    break;
                }
            ans += bj;
        }
        printf("%lld %lld\n", cnt, m - ans);
    }
    return 0;
}
